﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Ingebet.Model.Domain;

using Ingebet.Model.Domain;

using Ingebet.Repository.Contract;
using NHibernate;
using NHibernate.Criterion;

namespace Ingebet
{
    public class PariRepository : Repository<Pari, int>, IPariRepository
    {
        public bool GetPariByUtilIdRencontreID(int utilID, int rencID)
        {
            ISession s = HelperSessionFactory.GetCurrentSession();
            var result = s.CreateCriteria(typeof(Pari))
                    .Add(Restrictions.Eq("RencontreID", rencID))
                    .Add(Restrictions.Eq("UtilID", utilID))
                    .List();
            return (result.Count != 0) ? true : false;
        }

        public IList<Pari> GetByUtilId(int utilID)
        {
            ISession s = HelperSessionFactory.GetCurrentSession();
            var result = s.CreateCriteria(typeof(Pari))
                    .Add(Restrictions.Eq("UtilID", utilID))
                    .List<Pari>();
            return result;
        }

        public IList<Pari> UpdatePariByRencontre(int rencID)
        {
            ISession s = HelperSessionFactory.GetCurrentSession();
            var result = s.CreateCriteria(typeof(Pari))
                    .Add(Restrictions.Eq("RencontreID", rencID))
                    .List<Pari>();
            return result;
        }
    }
}